<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport"
		content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<meta content="telephone=no" name="format-detection" />
	<!-- 留作将来统一添加 -->
	<TEMPLATE>${TEMPLATE}</TEMPLATE>
	<title>模板html</title>
	<link rel="stylesheet" type="text/css" href="../../css/api.css">
	<link rel="stylesheet" type="text/css" href="../../css/index.css">
	<link rel="stylesheet" type="text/css" href="../../css/data-flex.min.css">
	<style type="text/css">
		body {
			background: rgba(255, 255, 255, 1);
		}

		.img {
			width: 132px;
			height: 80px;
			margin: 80px auto 19px auto;
		}

		.tips {
			height: 22px;
			font-size: 16px;
			font-weight: 400;
			color: rgba(63, 64, 70, 1);
			line-height: 22px;
			text-align: center;
		}

		.btns {
			margin-top: 50px;
			padding: 0 44px;
		}

		.btns .btn {
			min-width: 50%;
			height: 40px;
			border-radius: 20px;
			font-size: 14px;
			font-weight: 400;
			color: rgba(255, 255, 255, 1);
			background: rgba(90, 194, 255, 1);
		}

		.btns .btn:last-child {
			background: rgba(253, 155, 67, 1);
			margin-left: 15px;
		}
	</style>
</head>

<body>
	<div class="vueApp" v-cloak>
		<div v-if="isSuccess == '1'">
			<div class="img">
				<img src="../../image/ui/pay_true.png" alt="">
			</div>
			<div class="tips">支付成功</div>
			<div class="btns" data-flex>
				<div class="btn" v-if="from == 2" data-flex="main:center cross:center" data-flex-box="1" @click="backWatch()">
					返回继续观看
				</div>
				<div class="btn" v-else-if="from == 3" data-flex="main:center cross:center" data-flex-box="1" @click="viewOrder()">
					查看订单
				</div>
			</div>
		</div>
		<div v-if="!isSuccess">
			<div class="img">
				<img src="../../image/ui/pay_false.png" alt="">
			</div>
			<div class="tips">支付失败</div>
			<div class="btns" data-flex>
				<div class="btn" data-flex="main:center cross:center" data-flex-box="1" @click="togglePay()">
					其他支付方式
				</div>
				<div class="btn" data-flex="main:center cross:center" data-flex-box="1" @click="againPay()">
					继续支付
				</div>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/service/service-tool.js"></script>
<script type="text/javascript" src="../../script/service/service-app.js"></script>
<script type="text/javascript" src="../../script/service/service-user.js"></script>
<script type="text/javascript" src="../../script/service/service-logic.js"></script>
<script type="text/javascript" src="../../script/service/service-pay.js"></script>
<script type="text/javascript" src="../../script/jquery.min.js"></script>
<script type="text/javascript" src="../../script/vue.min.js"></script>
<script type="text/javascript">
	// html 的引号一律为双引号(""),js 为单引号('')
	var USER, $S, vm;
	var pageParam = {};
	apiready = function () {
		$S = SERVICE();
		USER = USER();
		console.log(JSON.stringify(api.pageParam) + '=====pageParam');
		pageParam = api.pageParam;
		fnInit();
        api.closeWin({
            name: pageParam.winName
        })
	};
	
	// 初始化
	function fnInit() {
		vm = new Vue({
			el: '.vueApp',
			data: {
				// 支付是否成功
				isSuccess: pageParam.result,
				from: pageParam.from,
				payMethod: pageParam.payMethod // （1:微信 2:支付宝 3:apple pay）
			}
		});
	}

	// 返回观看
	function backWatch() {
		api.closeToWin({
			name: 'video/detail_win'
		});
	}

	// 查看订单
	function viewOrder() {
		fnOpenPublicWin('订单详情','teacher/order_detail', {
            status: 2, // 未发货
            id: pageParam.orderId,
            orderIndex: -1
        });
	}

	// 切换支付方式 
	function togglePay() {
		fnDelayCloseWin();
	}

	// 再次尝试
	function againPay() {
		if(vm.payMethod == 1) {
			fnwxPayPlus(pageParam.retUrl)
		}else if(vm.payMethod == 2) {
			fnaliPayPlus(pageParam.retUrl)
		}else if(vm.payMethod == 3) {
			fnApplePay(pageParam.retUrl, pageParam.orderNo);
		}
	}

	// 支付回调
	function fnopenAudit(result) {
	    //1成功 0失败 -1某些情况下支付失败
	    if (result != -1) {
	        vm.isSuccess = result;
	    }
        if(result == 1) {
            api.execScript({
                name: pageParam.refreshWin,
                frameName: pageParam.refreshFrm,
                script: 'paySuccessCallback('+ pageParam.payMoney +')'
            });
        }
	}
</script>

</html>